<template>
    <div class='allAccount'>
      <Row :gutter='16' >
        <Col span='1'><span class='totalInfo'>共{{total}}条</span></Col>
        <Col span='11'><Page :total='100' :current='1' @on-change='changePage' show-elevator></Page></Col>
        <Col span='3'><Button type='primary' size='large' @click='exportData(1)'>导出用户名</Button></Col>
        <Col span='3'><Button type='primary' size='large' @click='exportData(2)'>删除无法登陆账号</Button></Col>
        <Col span='3'><Button type='primary' size='large' @click='exportData(3)'>删除被封账号</Button></Col>
      </Row>
      </br>
      <Row>
        <Table border stripe :columns='userAccount' :data='userdata' ></Table>
      </Row>
    </div>
</template>
<script>
export default {
  data () {
    return {
      total: 10,
      userAccount: [
        {
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '手机号',
          width: 120,
          key: 'phone'
        },
        {
          title: '用户名',
          key: 'uname',
          render: (h, params) => {
            return h('div', [
              h('Icon', {
                props: {
                  type: 'person'
                }
              }),
              h('strong', params.row.uname)
            ])
          }
        },
        {
          title: '名',
          key: 'ming'
        },
        {
          title: '姓',
          key: 'xing'
        },
        {
          title: '二级密码',
          key: 'secondPwd'
        },
        {
          title: '状态',
          key: 'state'
        },
        {
          title: '操作',
          key: 'action',
          width: 150,
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.show(params.index)
                    }
                  }
                },
                '修改'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'error',
                    size: 'small'
                  },
                  on: {
                    click: () => {
                      this.remove(params.index)
                    }
                  }
                },
                '删除'
              )
            ])
          }
        }
      ],
      userdata: []
    }
  },
  created () {
    Array.apply(null, { length: 20 }).map((k, v) => {
      this.userdata.push({
        phone: `1591111111${v}`,
        uname: `xiaofang${v}`,
        xing: `xing${v}`,
        ming: `ming${v}`,
        secondPwd: `二级密码${v}`,
        state: `正常`
      })
    })
  },
  methods: {
    show (index) {
      this.$Modal.info({
        title: 'User Info',
        content: `Name：${this.userdata[index].uname}<br>Age：${
          this.userdata[index].phone
        }<br>secondPwd：${this.userdata[index].secondPwd}`
      })
    },
    remove (index) {
      this.userdata.splice(index, 1)
    },
    changePage () {
      // The simulated data is changed directly here, and the actual usage scenario should fetch the data from the server
      this.tableData1 = this.mockTableData()
    },
    mockTableData () {
      console.info(11)
    },
    exportData (a) {
      alert(a)
    }
  }
}
</script>
<style lang='scss' scoped type='text/css'>
.allAccount {
  margin-top: 15px;
  .totalInfo {
    line-height: 3;
  }
}
</style>
